<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title class="title"></title>
    <base href="<%=basePath %>"/>
    <link rel="stylesheet" type="text/css" href="../commons/iconfont/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="../commons/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="../style/global.css"/>
    <script src="../js/jquery-3.3.1.min.js" type="text/javascript"></script>
    <script src="../commons/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script>
        function change(me) {
            $(".columnTitle>a").removeClass("layui-this");
            if (me.tagName == "LI") {
                $(".columnTitle li").removeClass("layui-this");
                $(".columnTitle>a").eq(0).addClass("layui-this");
            }
            $(me).addClass("layui-this");
        }
    </script>
</head>
<body>
<div class="fly-header layui-bg-black">
    <div class="layui-container"><a class="fly-logo" name="headlink" href="javascript:gotoIndex();"> <img
            src="../img/logo.png"
            alt="layui">
    </a>
        <ul class="layui-nav fly-nav layui-hide-xs">
            <li class="layui-nav-item layui-this"><a href="javascript:gotoIndex();"><i
                    class="iconfont icon-jiaoliu"></i>交流</a>
            </li>
            <li class="layui-nav-item"><a href="javascript:;"><i class="iconfont icon-chanpin"
                                                                 style="top: 1px;"></i>专区<span
                    class="layui-nav-more"></span></a>
                <dl class="layui-nav-child fly-nav-child layui-anim layui-anim-upbit">
                    <dd><a href="/vipclub/list/layuiadmin/">layuiAdmin</a></dd>
                    <hr>
                    <dd><a href="/vipclub/list/layim/">LayIM</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="http://www.layui.com/"><i class="iconfont icon-ui"></i>框架</a></li>
            <c:if test="${!empty currentUser}">
                <li class="layui-nav-item nav-user"><a class="fly-nav-avatar" href="/user/" id="LAY_header_avatar">
                    <cite
                            class="layui-hide-xs">${currentUser.nickName}</cite> <img
                        src="../upload/${currentUser.headImg}"><span
                        class="layui-nav-more"></span></a>
                    <dl class="layui-nav-child layui-anim layui-anim-upbit">
                        <dd><a href="javascript:gotoUserCenter();">用户中心</a></dd>
                        <dd><a href="javascript:gotoUserAset();">基本设置</a></dd>
                        <hr>
                        <dd><a href="javascript:gotoUserMsg();">我的消息</a></dd>
                        <dd><a href="/user/product/">已购产品</a></dd>
                        <dd><a href="javascript:gotoUserHomepage();">我的主页</a></dd>
                        <hr style="margin: 5px 0;">
                        <dd><a href="javascript:logOut();" style="text-align: center;">退出</a></dd>
                    </dl>
                </li>
            </c:if>
        </ul>
        <c:if test="${empty currentUser}">
            <ul class="layui-nav fly-nav-user">
                <li class="layui-nav-item"><a class="iconfont icon-touxiang layui-hide-xs"
                                              href="https://fly.layui.com/user/login/"></a>
                </li>
                <li class="layui-nav-item"><a href="../page/login-register.jsp">登入</a></li>
                <li class="layui-nav-item"><a href="../page/login-register.jsp">注册</a></li>
                <li class="layui-nav-item layui-hide-xs"><a href="https://fly.layui.com/app/qq/"
                                                            onclick="layer.msg('&#39;正在通过QQ登入&#39;, {icon:16, shade: 0.1, time:0}')"
                                                            title="QQ登入" class="iconfont icon-qq"></a></li>
                <li class="layui-nav-item layui-hide-xs"><a href="https://fly.layui.com/app/weibo/"
                                                            onclick="layer.msg('&#39;正在通过微博登入&#39;, {icon:16, shade: 0.1, time:0}')"
                                                            title="微博登入" class="iconfont icon-weibo"></a></li>
            </ul>
        </c:if>
    </div>
</div>
<div class="fly-panel fly-column">
    <div class="layui-container">
        <ul class="layui-clear columnTitle">
            <li onclick="gotoIndex()" class="layui-hide-xs  layui-this"><a
                    href="javascript:;">首页</a></li>
            <li onclick="gotoIndexToggleData(this)"><a href="javascript:;">提问</a></li>
            <li onclick="gotoIndexToggleData(this)"><a href="javascript:;">分享</a></li>
            <li onclick="gotoIndexToggleData(this)"><a href="javascript:;">讨论</a></li>
            <li onclick="gotoIndexToggleData(this)"><a href="javascript:;">建议</a></li>
            <li onclick="gotoIndexToggleData(this)"><a href="javascript:;">公告</a></li>
            <li onclick="gotoIndexToggleData(this)"><a href="javascript:;">动态</a></li>
            <c:if test="${!empty currentUser}">
                <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>
                <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="/user/post/">我发表的贴</a></li>
                <a href="/user/post/">我收藏的贴</a>
            </c:if>
        </ul>
        <div class="fly-column-right layui-hide-xs"><span class="fly-search LAY_search"><i
                class="layui-icon layui-icon-search"></i></span>
            <a href="https://fly.layui.com/jie/add/" class="layui-btn">发表新帖</a></div>
        <div class="layui-hide-sm layui-show-xs-block"
             style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
            <a href="https://fly.layui.com/jie/add/" class="layui-btn">发表新帖</a></div>
    </div>
</div>
<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md8 content detail">
            <div class="fly-panel detail-box">
                <h1 class="title"></h1>
                <div class="fly-detail-info"><span class="layui-badge layui-bg-green fly-detail-column"> 提问 </span>
                    <span class="layui-badge"
                          style="background-color: #999;">未结</span> <span class="fly-list-nums brNum"> </span></div>
                <div class="detail-about"><a class="fly-avatar homePage"> <img class="headImg" src=""> </a>
                    <div class="fly-detail-user"><a class="fly-link homePage nickName"></a> <span
                            class="createTime"></span>
                    </div>
                    <div class="detail-hits"><span class="kiss" style="padding-right: 10px; color: #FF7200"></span>
                    </div>
                </div>
                <div class="detail-body layui-text photos">
                    <table class="layui-table">
                        <tbody>
                        <tr>
                            <td>版本：layui</td>
                            <td>浏览器：</td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="context"></div>
                </div>
            </div>
            <div class="fly-panel detail-box" id="flyReply">
                <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
                    <legend>回帖</legend>
                </fieldset>
                <ul class="jieda" id="jieda">

                </ul>
                <div style="text-align: center"></div>
                <a name="comment"> </a>
                <div class="layui-form layui-form-pane">
                    <form action="" method="post">
                        <div class="layui-form-item layui-form-text">
                            <div class="layui-input-block"> <textarea id="L_content" name="content" required
                                                                      lay-verify="required" placeholder="请输入内容"
                                                                      class="layui-textarea fly-editor"
                                                                      style="height: 150px;"></textarea></div>
                        </div>
                        <div class="layui-form-item"><input type="hidden" name="jid" value="59389"> <input type="hidden"
                                                                                                           name="daPages"
                                                                                                           value="1">
                            <button type="button" class="layui-btn" lay-filter="*" lay-submit>提交回复</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="layui-col-md4">
            <dl class="fly-panel fly-list-one hotPost">
                <dt class="fly-panel-title">本周热议</dt>
            </dl>
            <div class="fly-panel">
                <div class="fly-panel-title"> 心级赞助商 <span class="fly-mid"></span> <a href="javascript:;"
                                                                                     class="fly-link">我要加入</a></div>
                <div class="fly-panel-main" style="padding: 13px 15px;"><a href="javascript:;"
                                                                           class="fly-zanzhu fly-zanzhu-img"
                                                                           id="fly-spm-event-diamonds-1"
                                                                           style="background: none;"> <img
                        src="../img/168_1557540349142_16350.png">
                </a> <a href="javascript:;" class="fly-zanzhu fly-zanzhu-img"
                        style="background: none;"> <img src="../img/168_1561705136068_74941.jpg">
                </a> <a href="javascript:;" class="fly-zanzhu"
                        style="background-color: #272894;">H5 代码生成工具 - 免费、开源</a></div>
            </div>
            <div class="fly-panel">
                <div class="fly-panel-title"> 官方产品</div>
                <div class="fly-panel-main"><a href="http://www.layui.com/admin/?from=fly" target="_blank"
                                               class="fly-zanzhu"
                                               time-limit="2017.09.25-2099.01.01"
                                               style="background-color: #20222A; background-image: linear-gradient(to right,#20222A,#3E4251);">layuiAdmin
                    - layui 官方后台管理模板</a> <a href="http://layim.layui.com/?from=fly" target="_blank" class="fly-zanzhu"
                                            time-limit="2017.09.25-2099.01.01"
                                            style="background-color: #009688; background-image: linear-gradient(to right,#009688,#5FB878);">LayIM
                    - layui
                    即时通讯旗舰之作</a></div>
            </div>
            <div class="fly-panel" style="padding: 20px 0; text-align: center;"><img src="../img/fukuan.png" style="max-width: 100%;" alt="layui">
                <p style="position: relative; color: #666;">微信扫码关注 layui 公众号</p>
            </div>
        </div>
    </div>
</div>
<div class="fly-footer">
    <p><a href="http://fly.layui.com/">Fly 社区</a> 2019 © <a href="http://www.layui.com/">layui.com</a></p>
    <p><a href="http://fly.layui.com/jie/3147/" target="_blank">付费计划</a> <a href="https://fly.layui.com/extend/"
                                                                            target="_blank">组件平台</a>
        <a href="https://fly.layui.com/store/" target="_blank">模板市场</a> <a href="https://fly.layui.com/case/2019/"
                                                                           target="_blank">年度案例</a>
        <a href="http://fly.layui.com/jie/2461/" target="_blank">公众号</a></p>
    <div class="fly-union">
        <p style="display: block; margin-bottom: 10px;"><span>感谢以下平台提供云加速支持</span></p>
        <p><a href="https://console.upyun.com/register/?invite=SJ0wu6g2-" target="_blank" rel="nofollow"
              sponsor="upyun">
            <img src="../img/upyun.png"> </a> <a href="https://www.maoyuncloud.com/?from=layui" target="_blank"
                                                 rel="nofollow"
                                                 sponsor="maoyun"> <img src="../img/168_1559291577683_9348.png"> </a>
        </p>
    </div>
</div>
<script>
    $(function () {
        let loc = location.href;//获取整个跳转地址内容
        let index = loc.indexOf("=");//取得=号的位置
        let postId = loc.substring(index + 1);
        loadHotPost();//加载本周热议
        $.post('../index/findPost', {"postId": postId}, function (result) {
            let data = result.data;
            let src = "../upload/" + data.headImg;
            console.log(src);
            $(".title").html(data.title);
            $(".headImg").attr("src", src);
            $(".kiss").html("悬赏：" + data.kiss + "飞吻");
            $(".createTime").html(data.createTime);
            $(".replyNum").html(data.replyNum);
            $(".browseNum").html(data.browseNum);
            $(".brNum").html("<a href=\"#comment\"><i class=\"iconfont\" title=\"回答\">&#xe60c;</i> " + data.replyNum + "</a> <i class=\"iconfont\" title=\"人气\">&#xe60b;</i> " + data.browseNum + " ")
            $(".context").html(data.context);
            $(".homePage").attr("href", "javascript:gotoUserHomepage(" + data.userId + ");");
            $(".nickName").html("<cite>" + data.nickName + "</cite>");
        });

        $.post('../reply/findReplyByPostId', {"postId": postId}, function (result) {
            let data = result.data;
            console.log(data);
            let html = "";
            let dataList = $("#jieda");
            dataList.empty(); //删除跳转页码前的数据
            for (var i = 0; i < data.length; i++) {
                html += '<li data-id="206369"><a name="item-1572707231813"></a>\n' +
                    '                <div class="detail-about detail-about-reply"><a class="fly-avatar" href="javascript:gotoUserHomepage(' + data[i].userId + ');"> <img\n' +
                    '            src="../upload/' + data[i].headImg + '"> </a>\n' +
                    '                <div class="fly-detail-user"><a href="avascript:gotoUserHomepage(' + data[i].userId + ');" class="fly-link"> <cite>' + data[i].nickName + '</cite>\n' +
                    '                </a></div>\n' +
                    '            <div class="detail-hits"><span>' + data[i].createTime + '</span></div>\n' +
                    '            </div>\n' +
                    '            <div class="detail-body layui-text jieda-body photos">' + data[i].replyContext + '</div>\n' +
                    '            <div class="jieda-reply"><span class="jieda-zan " type="zan"><i class="iconfont icon-zan"></i><em>' + data[i].praiseCount + '</em></span> <span type="reply">\n' +
                    '            <i class="iconfont icon-svgmoban53"></i>回复</span>\n' +
                    '            </div>\n' +
                    '            </li>';
            }
            dataList.append(html);
        });
        layui.use(['form', 'layer'], function () {
            let form = layui.form,
                layer = layui.layer;
            form.on('submit(*)', function (data) {
                if (${empty currentUser}) {
                    layer.msg("未登录");
                    return;
                }
                $.post('../reply/reply',
                    {
                        "postId": postId,
                        "replyContext": data.field.content,
                        "userId":"${currentUser.id}"
                    },
                    function (ret) {
                        if (ret.code == 1) {
                            layer.msg(ret.msg);
                            return;
                        }
                        gotoReplyPost(postId);
                    });
            });
        });
    });
</script>
<script src="../js/index.js"></script>
</body>
</html>
